<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增电子发票信息')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-invoice-add">
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">代理编号：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="agentId" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">发票图片：</label>
            <div class="col-sm-8">
                <div class="fileinput fileinput-new" data-provides="fileinput">
                    <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
                    <div>
                        <span class="btn btn-white btn-file"><span class="fileinput-new">选择图片</span><span class="fileinput-exists">更改</span>
                            <input type="file" name="file" accept="image/*"></span>
                        <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">代理商名称：</label>
            <div class="col-sm-8">
                <input type="text" name="agentName" id="agentName" readonly onclick="queryAgent()"
                       placeholder="选择代理商" class="form-control" maxlength="30">
                <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                <input type="hidden" name="agentId" id="agentId">
                <input type="hidden" name="applyAgentId" id="applyAgentId">
            </div>
        </div>
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">发票来源：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="source" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">操作员姓名：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="operatorName" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">发票金额：</label>
            <div class="col-sm-8">
                <input name="amount" class="form-control" placeholder="发票金额（单位：元）" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">发票代码：</label>
            <div class="col-sm-8">
                <input name="invoiceCode" class="form-control" placeholder="发票代码(唯一)，国家税务总局分配的10/12位代码" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">纳税人识别号：</label>
            <div class="col-sm-8">
                <input name="taxpayerNo" class="form-control" placeholder="纳税人识别号（税务登记号）" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">发票号码：</label>
            <div class="col-sm-8">
                <input name="invoiceNo" class="form-control"  placeholder="发票号码(唯一)，8位或20位号码" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">税率百分比：</label>
            <div class="col-sm-8">
                <input name="taxRatio" class="form-control" placeholder="税率百分比（格式示例：3%, 13%）" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">税额：</label>
            <div class="col-sm-8">
                <input name="tax" class="form-control" placeholder="税额（单位：元）" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">开票时间：</label>
            <div class="col-sm-8">
                <input type="text" class="time-input"  name="invoiceTime" data-type="datetime" placeholder="开票时间（精确到秒）" data-format="yyyy-MM-dd HH:mm:ss"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">摘要：</label>
            <div class="col-sm-8">
                <input name="invoiceContent" class="form-control" placeholder="发票内容" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">快递单号：</label>
            <div class="col-sm-8">
                <input name="trackingNo" class="form-control" placeholder="快递单号（默认0表示电子发票）" type="text">
            </div>
        </div>
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">子代理商ID：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="subAgentId" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">发票状态：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <div class="radio-box">-->
<!--                    <input type="radio" name="status" value="">-->
<!--                    <label th:for="status" th:text="未知"></label>-->
<!--                </div>-->
<!--                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>-->
<!--            </div>-->
<!--        </div>-->
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: jasny-bootstrap-js" />
<script th:inline="javascript">
    var prefix = ctx + "channel/invoice"
    $("#form-invoice-add").validate({
        focusCleanup: true
    });

    $("input[name='date']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var formData = new FormData($("#form-invoice-add")[0]);
            $.ajax({
                url : prefix + "/add",
                type: 'POST',
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍后...");
                    $.modal.disable();
                },
                success : function(result) {
                    if (result.code == web_status.SUCCESS) {
                        var parent = window.parent;
                        if (parent.table.options.type == table_type.bootstrapTable) {
                            $.modal.close();
                            parent.$.modal.msgSuccess(result.msg);
                            parent.$.table.refresh();
                        } else if (parent.table.options.type == table_type.bootstrapTreeTable) {
                            $.modal.close();
                            parent.$.modal.msgSuccess(result.msg);
                            parent.$.treeTable.refresh();
                        } else {
                            $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
                        }
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    }  else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                    $.modal.enable();
                    //$.modal.alertSuccess(data.msg)
                },
                error : function(result) {
                    $.modal.alertError(result.msg);
                }
            });
        }
    }
    function queryAgent() {
        $.modal.open("选择代理商", ctx + "channel/agent/queryAgentInfo","1200", "600");
    }
    function queryWithdraw() {

    }
</script>
</body>
</html>